package 运输配货系统;

import java.util.Scanner;

public class Order {

	
	private static int count=0;//总共有多少的订单
	private static int orderNumber1=100000;//代表订单号上线
	private static int []orderNumber2=new int[5];//最大订单编号
	
	int []orderNumber=new int[5];// 订单编号
	
	String sendName;    //寄件人名
	String receiver ;    //收件人名
	int []telephoneNumber_sendName=new int[11];//电话 寄件人
	int []telephoneNumber_receiver=new int[11];  //电话 收件人
	Address firstAddress;  //寄件人地址
	Address lastAddress;       //收件人地址
	int []userId=new int[7];        //用户ID
	int carGroupNumber;   //第几组车为你配送
	int carGroupNumberIndex ;//第几组车中的第几个车为你配送（暂时不用）
	int []carNumber=new int[5];//车牌号
	
	public  Order( User user,office office1)   
	{
		
		
		
		
		label:  for(int i=0;i<office1.cargroup.length;i++)
		{
			for(int j=0;j<office1.cargroup[i].a.length;j++ )  //a为Car类型的数组;
			{
				
				if(office1.cargroup[i].a[j].bool==false)
				{             carGroupNumber=office1.cargroup[i].cargroup ;
				              office1.cargroup[i].a[j].bool=true;
				              carGroupNumberIndex =j;
				              for(int k=0;k<5;k++)
				            	this.carNumber[k]= office1.cargroup[i].a[j].carNumber[k];
				             break label;
				}
				
				else if(i==office1.cargroup.length-1&&j==office1.cargroup[i].a.length-1)
				{ System.out.println("车辆紧张，请稍后再试") ;
				
				
				return ;}
			}
			                                                                    
		
		}
		
		
		
		
		
		
		
		
		
		
		this.count++;
		orderNumber1++;
		int x=10000;
		for(int i=0;i<5;i++) {
		orderNumber[i]=(orderNumber1/x)%10;
		orderNumber2[i]=(orderNumber1/x)%10;
		x=x/10;

		
		
	}
		
		
		sendName=user.name;
		for(int i=0;i<11;i++)
			telephoneNumber_sendName[i]=user.number[i];
		firstAddress=user.address;
		System.out.println("请输入收件人名 电话后再输入  收件人地址");
		Scanner input =new Scanner(System.in);
		receiver=input.next();
		String number1=input.next();
	if(number1.length()==11)
	{
		for(int i=0;i<number1.length();i++) {
			int j=number1.charAt(i)-48;
			if(j>=0&&j<10) {
				telephoneNumber_receiver[i]=j;
			}
			else {
				System.out.println("手机号输入格式错误（非数字）");
				
			     }
				
			
		}
	}
	else {
		System.out.println("手机号输入格式错误(长度)");
	     }
	        
		lastAddress=new Address();
		for(int i=0;i<7;i++) {
			userId[i]=user.id[i];
		}
		
	}
	
	public static String toString(int [] a) {
		String s="";
		
		for(int i=0;i<a.length;i++)
			s=s+a[i];
		return s;
	}
	public static int  getCount() {
		return count;
	}
	public static void setCount() {
		count--;
	}
	
	public static String getMaxOrderNumber() {
		return toString(orderNumber2);
	}
	public String getOrderNumber() {
		return toString(orderNumber);
	}
	public String getSendName() {
		return sendName;
	}
	public void setSendName(String sendName) {
		this. sendName=sendName;
	}
	public String getReceivrName() {
		return receiver;
	}
	public void setReceivrName(String receiver) {
		this.receiver= receiver;
	}
	public String getTelephoneNumber_sendName() {
	return toString(telephoneNumber_sendName);
	}
	public void setTelephoneNumber_sendName(int []a) {
	for(int i=0;i<a.length;i++) {
	this.telephoneNumber_sendName[i]=a[i];
	}
		}
	public String getTelephoneNumber_receiverName() {
		return toString(telephoneNumber_receiver);
		}
	public void setTelephoneNumber_receiver(int []a) {
		for(int i=0;i<a.length;i++) {
		this.telephoneNumber_receiver[i]=a[i];
		}
	}
		public String getFirstAddress () {
			String s=firstAddress.province+firstAddress.city+firstAddress.county;
			return s;
		}
		
		public void setFirstAddress () {
			
			firstAddress=new Address();
			
		}
		public String getLastAddress () {
			String s=lastAddress.province+lastAddress.city+lastAddress.county;
			return s;
		}
		
		public void setlastAddress () {
			
			lastAddress=new Address();
			
		}
		public String getUserID() {
			return toString(userId);
		}
		public int getCarGroupNumber() {
			return carGroupNumber;
		}
		public String getCarNumber() {
		return toString(carNumber);
		}
		
			
}
